home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3250 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.3 KB

  1. Path: news.rain.org!usenet
  2. From: "Guus Leeuw jr." <guusl@eiffel.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Getting the system time and date
  5. Date: Mon, 22 Jan 1996 14:39:27 -0800
  6. Organization: ISE Inc. http://www.eiffel.com
  7. Message-ID: <3104121E.41FC143C@eiffel.com>
  8. References: <tate.1.002C7F92@netwest.com> <4e0dm2$pv4@hasle.sn.no>
  9. NNTP-Posting-Host: @outback.eiffel.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b3 (X11; I; Linux 1.2.8 i586)
  14.  
  15. Lars-Inge Tonnessen wrote:
  16. > tate@netwest.com (Tate Griffin) wrote:
  17. > >How do I get the current time and date from a PC using C++?
  18. > You can use a lib that is called "time.h".  Your compiler should
  19. > contain it, as it's standard ANSI C.
  20. > // Example by Lars-Inge Tonnessen 1996
  21. > #include <time.h>
  22. >         .
  23. >         .
  24. >         .
  25. > void main(void)
  26. > {
  27. > tm Times;
  28. > cout <<asctime(&Times);
  29. > }
  30. > When you run the application, it should return:
  31. > Sun  Jan  21  21:25:16  1996
  32.  
  33. On my machine (Pentium 120 Linux) it returned
  34.  
  35. Mon Jan 22 14:35:34 1996
  36.  
  37. How could that be ;-)
  38.  
  39. > Take a look at the "time.h" file.  It contains allmost everything that
  40. > has to do with the time and date.
  41. > Lars-Inge Tonnessen
  42. > larsit@sn.no
  43.  
  44. Guus Leeuw jr.
  45.